<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			
			/**
			function test(){
				var a = 123;
				var b = 234;
				var c = a + b;
				document.write(c);
			}
			test();
			*/
			
			/**
			function theFirstName() {}
			document.write(theFirstName);
			*/
			
			//等号后面就是表达式，表达式abc没有用
			/**
			var test = function abc() {}//命名函数表达式
			console.log(test.name);//abc
			console.log(test);
			*/
			
			
			/**
			var test = function(){ //命名函数表达式
				document.write("a");
			}
			console.log(test.name);//test
			console.log(test);
			*/
			
//传参数
			/**
			function sum(a,b){
				document.write(a + b);
			}
			sum(1,2);
			*/
			
			/**
			function sum(a,b){  //形参
				if(a >10){
					document.write(a - b);
				}eles if(a < 10){
					document.write(a + b);
				}else{
					document.write(a);
				}
				
			}
			sum(1,2);//实参
			*/
			/**
			function sum(a,b,c,d){
				console.log(a);
				console.log(b);
				console.log(c);
				console.log(d);//undefined
			}
			sum(11,2,3);
			*/
			
			/**
			//arguments -->实参列表
			function sum(a){
				console.log(arguments.length);//实参长度
				console.log(sum.length);//形参长度
				console.log(arguments);
			}
			sum(11,2,3);
			*/
			
			/**
			//任意个数求和
			function sum(){
				var result;
				for (var i = 0; i < result += arguments.length; i++) {
					result += arguments.[i];
				}
				console.log(result);
			}
			sum(1,2,3,4,5,6,7,8,9,10);
			*/
			
			/**
			function sum(a,b){
				//arguments [1,2]
				//var a = 1
				a = 2;
				console.log(arguments[0]);//一个变另一个跟着变
				arguments[1] = 10;
				console.log(b);
			}
			sum(1,2);
			*/
			
			/**
			function sum(a,b){
				//arguments [1,2]
				//var a = 1
				b = 2;
				console.log(arguments[0]);//1
				console.log(arguments[1]);//undefined
			}
			sum(1);
			*/
			
//返回值         -->结束函数/返回值
			
			/**
			function sum(a,b){
				console.log(a);
				console.log(b);
				return;
			}
			sum(1,2);
			*/
			
			function myNumber(target){
				return +target;
			}
		</script>
	</body>
</html>
